From 3bac1a54a2c50bb8435ad573023bf4300a3e309a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Fri, 16 Dec 2016 00:39:08 +0100 Subject: [PATCH] extensions: add fast paths going from gray to premul alpha rgb - for resampling --- extensions/gggl-lies.c | 25 +++++++++++++++++++++++++ extensions/gggl.c | 24 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/extensions/gggl-lies.c b/extensions/gggl-lies.c index 5d50f5b..b8efc83 100644 --- a/extensions/gggl-lies.c +++ b/extensions/gggl-lies.c @@ -418,6 +418,29 @@ conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples) return samples; } + +static long +conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples) +{ + long n = samples; + + while (n--) + { + *(int *) dst = (*(int *) src); + dst += 4; + *(int *) dst = (*(int *) src); + dst += 4; + *(int *) dst = (*(int *) src); + dst += 4; + *(float *) dst = 1.0; + dst += 4; + src += 4; + } + return samples; +} + +#define conv_gF_rgbAF conv_gF_rgbaF + static long conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples) { @@ -840,6 +863,8 @@ init (void) o (gaF, ga8); o (gAF, gA8); o (gF, g8); + o (gF, rgbAF); + o (gF, rgbaF); o (ga8, gaF); o (gA8, gAF); o (g8, gF); diff --git a/extensions/gggl.c b/extensions/gggl.c index c4b8ce4..b01659f 100644 --- a/extensions/gggl.c +++ b/extensions/gggl.c @@ -607,6 +607,28 @@ conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples) return samples; } +static long +conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples) +{ + long n = samples; + + while (n--) + { + *(int *) dst = (*(int *) src); + dst += 4; + *(int *) dst = (*(int *) src); + dst += 4; + *(int *) dst = (*(int *) src); + dst += 4; + *(float *) dst = 1.0; + dst += 4; + src += 4; + } + return samples; +} + +#define conv_gF_rgbAF conv_gF_rgbaF + /* static long conv_rgb8_rgbaF (unsigned char *src, @@ -1102,6 +1124,8 @@ init (void) o (gF, gaF); o (gF, gAF); o (gF, rgbF); + o (gF, rgbaF); + o (gF, rgbAF); o (gaF, rgbaF); o (gAF, rgbAF); o (rgbaF, rgb8); -- 2.30.2